import type { AxiosResponse } from 'axios';

const modulesFiles = require.context('./modules', false, /\.ts$/)
  .keys();

const api: {
  // eslint-disable-next-line
  [key: string]: { [key: string]: (data?: any) => Promise<AxiosResponse> }
} = {};

modulesFiles.forEach((modulePath) => {
  const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1');
  // eslint-disable-next-line
  const apiModule = require(`./modules/${moduleName}`);
  api[moduleName] = apiModule.default;
});

export default api;
